﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using com.clinica.business.BE.gesliq;

namespace wesiGestClinica.gesliq.popups
{
    public partial class FormsPopupBuscarPaciente : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Expires = 0;
            Response.CacheControl = "no-cache";
            Page.Header.Controls.Add(new LiteralControl(@"<base target=""_self"" />"));
            if (!Page.IsPostBack)
            {
                Master.TituloModulo = "Consulta de Pacientes";
                string TipoBus = string.Empty;
                if(Request.QueryString["tipbus"].ToString().Trim()!=string.Empty)
                    TipoBus = Request.QueryString["tipbus"].ToString();
                ucBusPaciente.txt_Numero_Documento.Text = Request.QueryString["nundoc"].ToString();
                if (ucBusPaciente.txt_Numero_Documento.Text.Trim() != string.Empty)
                    ucBusPaciente.TipoBus = 2;        
            }
            ucBusPaciente.dgPaciente.RowCommand += new GridViewCommandEventHandler(dgPaciente_RowCommand);
        }

        void dgPaciente_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Seleccionar")
            {
                GridViewRow fila = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer;
                ucBusPaciente.dgPaciente.SelectedIndex = fila.RowIndex;
                string[] arr = e.CommandArgument.ToString().Split(new char[] { '|' });
                hdfDocumento.Value = arr[0];
                hdfNombreCompleto.Value = arr[1];
                ScriptManager.RegisterStartupScript(this, typeof(Page), "Envio", "enviarParam('" + arr[0] + "','" + arr[1] + "','" + arr[2] + "');", true);
            }
        }     
        
    }
}
